#pragma once

//
class CEchoTestDlg;
class COcfClient;

//
typedef __OCF_BASE__::CBaseThread<__OCF_BASE__::CMemPoolDefaultAllocator> _OCFTHREAD_T;
typedef __OCF_BASE__::CTcpCommCli<__OCF_BASE__::CMemPoolDefaultAllocator> _OCFCLI_T;

//
#define __USE_THREAD_FOR_CLI__

#ifdef __USE_THREAD_FOR_CLI__
class COcfClient: protected _OCFTHREAD_T,  public _OCFCLI_T
{
#else
class COcfClient: public _OCFCLI_T
{
#endif
public:
	COcfClient(CEchoTestDlg* pcMain);
	virtual ~COcfClient();

	BOOL InitCli();
	void UninitCli();
	long Send(const BYTE byST, const ULONG ulLen, const BYTE* pbyData);

public:
#ifdef __USE_THREAD_FOR_CLI__
	virtual BOOL _OCFTHREAD_T::Do();
#else
	virtual BOOL Do();
#endif
	virtual void Pop(LONG lLen, const unsigned char* pchData, LONG& lUsedLen);
	virtual void HandleSessionTimeout();
	virtual void HandleError(TCPCOMMCLI_ERROR_CATEGORY enumErrorCategory, LONG ErrorCode, LONG lLen = 0, const BYTE* pchData = NULL);
	virtual void HandleConnect();
	virtual void HandleClose();
	virtual void OnPacket(BYTE byST, ULONG ulLen, const BYTE* pbyData);

private:
	CEchoTestDlg* m_pcMain;
};

